import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';

export default tseslint.config(
  { ignores: ['dist'] },
  {
    extends: [js.configs.recommended, ...tseslint.configs.recommended],
    files: ['**/*.{ts,tsx}'],
    languageOptions: {
      ecmaVersion: 2020,
      globals: globals.browser,
    },
    plugins: {
      'react-hooks': reactHooks,
      'react-refresh': reactRefresh,
    },
    rules: {
      ...reactHooks.configs.recommended.rules,
      'react-refresh/only-export-components': [
        'warn',
        { allowConstantExport: true },
      ],

      //分号结尾
      semi: ['error', 'always'],
      //单引号
      quotes: ['error', 'single'],
      //禁止使用var
      'no-var': 'error',
      //强制使用一致的缩进
      indent: ['error', 2],
      //禁止修改const声明的变量
      'no-const-assign': 'error',
      //禁止出现未使用的变量
      'no-unused-vars': 'warn',
      //禁止使用console
      'no-console': 'warn',
    },
  },
);
